# coding=utf-8
# 全世界最帅的帅哥
from flask import g

from ysgg1_club_comment.utils.base_serializers import BasePaginateSerializer
from ysgg1_club_subject.subject_views.liked_views import is_liked, get_liked_count


class SubjectInfoPaginateSerializer(BasePaginateSerializer):

    def get_object(self, obj):
        return {
            "subject_id": obj.SubjectInfo.id,
            "subject_name": obj.SubjectInfo.subject_name,
            "category_id": obj.category_id,
            "label_id": obj.label_id,
            "liked": is_liked(str(obj.SubjectInfo.id), g.token),
            "count": get_liked_count(str(obj.SubjectInfo.id))
        }
